package com.fhz.module_main.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.fhz.module_main.databinding.RecommendTextCardLayoutBinding
import com.fhz.module_main.entity.RecommendEntity
import com.fhz.module_main.entity.TextCard

/**
 * 时间:2023/5/10
 * @author Mr.Feng
 * 简述: TODO
 */
class TestAdapter : BaseQuickAdapter<RecommendEntity.Data, TestAdapter.VH>() {

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val binding: RecommendTextCardLayoutBinding = RecommendTextCardLayoutBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: RecommendEntity.Data?) {
        // 设置item数据
        if (item != null) {
            holder.binding.recommendTvTextCard.text = item.text
        }
    }

}